package com.bahehe.taoyunabus;





import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TabHost;

public class MainActivity extends TabActivity {
private  TabHost tabHost; 
	
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  
        setContentView(R.layout.main);
        


        tabHost = getTabHost();  
		LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true);
		tabHost.setBackgroundColor(Color.argb(150, 22, 70, 150));
        
        tabHost.addTab(tabHost.newTabSpec("tab1")  
                .setIndicator(getResources().getString(R.string.category_bus_businfo),getResources().getDrawable(R.drawable.bus))  
                .setContent(new Intent(this, BusInfo.class)));  
//        tabHost.addTab(tabHost.newTabSpec("tab2")  
//                .setIndicator(getResources().getString(R.string.category_bus_favor),getResources().getDrawable(R.drawable.star))  
//                .setContent(new Intent(this,MyFavor.class)));
//        tabHost.addTab(tabHost.newTabSpec("tab3")  
//                .setIndicator(getResources().getString(R.string.category_bus_nearstop),getResources().getDrawable(R.drawable.find))  
//                .setContent(new Intent(this,NearStop.class)));  
//        tabHost.addTab(tabHost.newTabSpec("tab4")  
//                .setIndicator(getResources().getString(R.string.category_bus_notice),getResources().getDrawable(R.drawable.clock))  
//                .setContent(new Intent(this, BusAlarm.class))); 
  
        tabHost.setCurrentTab(0); 
    }
    
    
    @Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK) {
	        //Ask the user if they want to quit
	        new AlertDialog.Builder(this)
	        .setIcon(android.R.drawable.ic_dialog_alert)
	        .setTitle(getResources().getString(R.string.exitwaring))
	        .setMessage(getResources().getString(R.string.exitmessage))
	        .setPositiveButton(getResources().getString(R.string.exitApp), new DialogInterface.OnClickListener() {

	            @Override
	            public void onClick(DialogInterface dialog, int which) {
	                //Stop the activity
	                MainActivity.this.finish();    
	            }

	        })
	        .setNegativeButton(getResources().getString(R.string.cancelexitApp), null)
	        .show();

	        return true;
	    }
	    else {
	        return super.onKeyDown(keyCode, event);
	    }
	//	return super.onKeyDown(keyCode, event);
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		
		super.onDestroy();
	}



	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}
}
